package com.yunheone.view.Teach;

import com.yunheone.Jdbc.TeacherJdbc;
import com.yunheone.control.Teachcon;
import com.yunheone.mode.TeacherUser;

import java.util.List;
import java.util.Scanner;
import java.util.function.BiConsumer;

/**
 * 讲师管理页面
 */
public class TeachList {
    public static int list() {
        System.out.println ( "*********学员信息管理系统—讲师管理*********" );
        System.out.println ( "编号\t\t用户名\t\t性别\t\t年龄" );
        List<TeacherUser> list = TeacherJdbc.list ();
        list.forEach ( teacherUser->System.out.println (teacherUser.getId ()+"\t\t"+teacherUser.getName ()+"\t\t"+teacherUser.getSex ()
                +"\t\t"+teacherUser.getAge ()) );
        System.out.println ( "1.添加讲师    2.删除讲师    3.返回主页" );
        Scanner input = new Scanner ( System.in );
        System.out.print ( "请输入操作序号：" );
        try {
            int i = input.nextInt ();
            if (i > 3 || i < 1) {
                throw new Exception ( "操作序号未识别" );
            }
            return i;
        } catch (Exception e) {
            String message = e.getMessage ();
            System.out.println ( message != null ? message : "输入不合法" );
            return list ();
        }
    }
}
